package com.six.work.controller;

import com.six.work.entity.Admin;
import com.six.work.entity.Applicant;
import com.six.work.entity.CompanyAndPositionView;
import com.six.work.entity.Resume;
import com.six.work.services.ResumeServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("resume")
public class ResumeController {
    @Autowired
    private ResumeServices resumeServices;

    @GetMapping("/list")
    public List<CompanyAndPositionView> findAllResumeByComID(Integer company_id) {
        List<CompanyAndPositionView> list = resumeServices.findAllResumeByComID(company_id);
        return list;
    }

    //后台管理中查看求职者的简历

    @PostMapping("/add")
    public Integer InsertResume(@RequestBody Resume resume){

        return resumeServices.insertResume(resume);
    }

    @GetMapping("/update")
    public Resume getUpdatePage(@RequestParam("applicant_id") Integer applicant_id){

        return resumeServices.SelectResumeByID(applicant_id);
    }

    @PostMapping("/update")
    public Integer UpdateResume(@RequestBody Resume resume) {
        return resumeServices.updateResume(resume);
    }

    @GetMapping("/unilist")
    public List<CompanyAndPositionView> findResByUniversity(@RequestParam(value = "resume_university", defaultValue = "")String resume_university,
                                                            @RequestParam(value = "company_id", defaultValue = "0")Integer company_id) {
        List<CompanyAndPositionView> list = resumeServices.findResByUniversity(resume_university,company_id);
        return list;
    }


    @GetMapping("/skilist")
    public List<CompanyAndPositionView> findResBySkill(@RequestParam(value = "resume_skill",defaultValue = "") String resume_skill,
                                                       @RequestParam(value = "company_id",defaultValue = "0") Integer company_id) {
        List<CompanyAndPositionView> list = resumeServices.findResBySkill(resume_skill,company_id);
        return list;
    }

    @GetMapping("/explist")
    public List<CompanyAndPositionView> findResByExp(@RequestParam(value = "resume_experience",defaultValue = "") String resume_experience,
                                                     @RequestParam(value = "company_id",defaultValue = "0") Integer company_id) {
        List<CompanyAndPositionView> list = resumeServices.findResByExp(resume_experience,company_id);
        return list;
    }

    //前端页面talent传值到postItemC
    @GetMapping("/post")
    public List<Resume> SelectResByID(@RequestParam("resume_id")Integer resume_id) {
        return resumeServices.SelectResByID(resume_id);
    }


    //求职者查看公司职位信息然后投递简历
    @GetMapping("/list2")
    public List<Resume> findAllResumeByAppID(@RequestParam("applicant_id")Integer applicant_id) {
        List <Resume> list = resumeServices.findAllResumeByAppID(applicant_id);
        return list;
    }
}
